<template>
  <div class="nav-control">
    <div
      v-for="(item, index) in navitem"
      :key="index"
      class="nav-control-item"
      @click="changeItem(index)"
    >
      <span :class="{ active: index == currentIndex }">
        {{ item }}
      </span>
    </div>
  </div>
</template>
<script>
export default {
  data: () => ({
    currentIndex: 0
  }),
  props: {
    navitem: Array,
    default() {
      return []
    }
  },
  methods: {
    changeItem(index) {
      this.currentIndex = index
      this.$emit('changeType',index)
    }
  }
}
</script>
<style scoped>
.nav-control {
  display: flex;
  text-align: center;
  font-size: 15px;
  background-color: #fff;
  position: sticky;
  top: 44px;
}
.nav-control-item {
  flex: 1;
  height: 40px;
  line-height: 40px;
}
.active {
  border-bottom: 3px solid pink;
  padding: 5px;
  color: pink;
}
</style>